package com.briup.sms.storage;

import com.briup.sms.model.Student;
import com.briup.sms.model.User;

class Main {
    public static void main(String[] args) {
        // 在实际使用泛型类时，需要指定一个确定的类型来替代原本作为标识的T
        Storage<Student> storage = new Storage<>();
        // 使用Storage对象存储学生数据
        /*storage.add(1);
        storage.add("abx0");
        storage.add(new User());*/
        storage.add(new Student());
        System.out.println(storage);
        // 获取学生数据
        Student o = storage.get(0);

        // 存储用户数据
        Storage<User> userStorage = new Storage<>();
        userStorage.add(new User());
        User user = userStorage.get(0);

        // 存储字符串数据
        Storage<String> stringStorage = new Storage<>();
        stringStorage.add("123");
    }

    private static void test() {
        UserStorage storage = new UserStorage(3);
        User[] users = new User[6];
        for (int i = 0; i < 5; i++) {
            User user = new User("李四", "123" + i, "user");
            storage.add(user);
            users[i] = user;
        }
        users[5] = new User("张三", "123", "admin");
        storage.add(users);
        System.out.println(storage.getSize());
        System.out.println(storage);
        // 删除第一个李四
        User delete = storage.delete(0);
        System.out.println(delete);
        System.out.println(storage.getSize());
    }
}
